import { createRouter, createWebHistory } from 'vue-router'
// 引入漂流瓶页面组件
import DriftBottleMain from '../views/DriftBottleMain.vue'
import DriftBottleHistory from '../views/DriftBottleHistory.vue'
// 引入DriftBottle文件夹中的子页面组件
import People from '../views/DriftBottle/People.vue'
import RetrieveBottle from '../views/RetrieveBottle.vue'
import LossBottle from '../views/DriftBottle/LossBottle.vue'
import ReceivedBottles from '../views/ReceivedBottles.vue'

const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes: [
    {
      path: '/',
      name: 'home',
      redirect: '/drift-bottle'
    },
    {
      path: '/404',
      name: 'NotFound',
      meta: { title: '404找不到页面' },
      component: () => import('../views/404.vue')
    },
    {
      path: '/Community',
      name: 'Community',
      meta: { title: '运动论坛' },
      component: () => import('../views/Community.vue')
    },
    {
      path: '/AddCommunity',
      name: 'AddCommunity',
      meta: { title: '发布帖子' },
      component: () => import('../views/AddCommunity.vue')
    },
    {
      path: '/ShowCommunity',
      name: 'ShowCommunity',
      meta: { title: '帖子详情' },
      component: () => import('../views/ShowCommunity.vue')
    },
    // 漂流瓶主页面路由
    {
      path: '/drift-bottle',
      name: 'DriftBottle',
      component: DriftBottleMain,
      meta: { title: '漂流瓶' },
      children: [
        {
          path: '',
          name: 'DriftBottlePeople',
          component: People,
          meta: { title: '漂流瓶广场' }
        },
        {
          path: 'received',
          name: 'ReceivedBottles',
          component: ReceivedBottles,
          meta: { title: '收到的瓶子' }
        },
        {
          path: 'my-bottles',
          name: 'MyBottles',
          component: DriftBottleHistory,
          meta: { title: '我的瓶子' }
        }
      ]
    }
  ]
})
//from将要进行跳转的当前route对象(跳转前的一些操作)
//to:跳转后route对象(跳转后的一些操作)
//next():调用该方法后，才能进入下一个钩子
//beforeEach 表示跳转之前的一些操作


export default router